<?php
require_once("Carapi.php");
$str='{"clientNo":"channels_1_2","payType":"cash","parkingTime":"263352","parkingName":"闲林山水停车场","leftCounts":"971","outChannelNo":"2","parkingEndTime":"20200917185110","outOpr":"123","outChannelName":"出口","version":"V1.0","carPlateNo":"临LS4241","parkingOrderNo":"20200914174201034-810530954","bizCode":"B1011","carColor":"1","sign":"ED6A09764F7C69A170F2F562384A2DCC","amountRec":"1","amountDue":"1","reqNo":"20200917185119950-285636","parkingNo":"600006","parkingStartTime":"20200914174159"}';
$indata=json_decode($str,true);
$fd=3;
$res=(new Carapi2())->carout($indata);
var_dump($res);die;
function MakeSign($arr,$parkingKey){
    //签名步骤一：按字典序排序参数
    ksort($arr);
    $string = ToUrlParams($arr);
    //return $string;
    //签名步骤二：在string后加入KEY
    $string = $string . "&key=" . $parkingKey;
    //签名步骤三：MD5加密
    $string = md5($string);
    //签名步骤四：所有字符转为大写
    $result = strtoupper($string);
    return $result;
}
//格式化参数格式化成url参数(str)
function ToUrlParams($value){
    $buff = "";
    foreach($value as $k => $v){
        if($k != "sign" && $v != "" && !is_array($v)){
            $buff .= strtolower($k) . "=" . $v . "&";
        }
    }
    $buff = trim($buff, "&");
    return $buff;
}
function jsondata($arr){
    $str='{';
    foreach($arr as $key =>$value){
        $str=$str.'"'.$key.'":"'.$value.'",';
    }
    $str = trim($str, ",");
    $str=$str.'}';
    return $str;
}
